package com.liuweiheng.cloudproviderpayment8002.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Redisson配置类
 *
 * @author lwh
 */
@Configuration
public class RedissonConfig {

    @Value("${redisson.address}")
    private String addressUrl;


    /**
     * 获取Redisson
     *
     * @return Redisson操作对象
     */
    @Bean
    public RedissonClient getRedisson() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress(addressUrl)
                .setReconnectionTimeout(10000)
                .setRetryInterval(5000)
                .setTimeout(10000)
                .setConnectTimeout(10000)
                .setConnectionMinimumIdleSize(10);
        return Redisson.create(config);
    }


}
